﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

/// <summary>
/// Summary description for MembershipExtender
/// </summary>
public class MembershipExtender
{
    public MembershipExtender()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public static List<UserProfile> GetAll()
    {
        List<UserProfile> users = new List<UserProfile>();
        MembershipUserCollection usersCollection = null;
        usersCollection = Membership.GetAllUsers();
        foreach (MembershipUser user in usersCollection)
        {
            users.Add(new UserProfile { Email = user.Email, UserName = user.UserName, IsLockedOut = user.IsLockedOut });
        }
        return users;
    }

    public static List<UserProfile> GetUserInRole(string roleName)
    {
        List<UserProfile> users = new List<UserProfile>();
        if (!string.IsNullOrEmpty(roleName))
        {
            foreach (string s in Roles.GetUsersInRole(roleName))
            {
                users.Add(new UserProfile { UserName = s });
            }
        }
        return users;
    }
}